<?php
/*******************************************************************************
*  Title: Help Desk Software HESK
*  Version: 2.2 from 9th June 2010
*  Author: Klemen Stirn
*  Website: http://www.hesk.com
********************************************************************************
*  COPYRIGHT AND TRADEMARK NOTICE
*  Copyright 2005-2010 Klemen Stirn. All Rights Reserved.
*  HESK is a registered trademark of Klemen Stirn.

*  The HESK may be used and modified free of charge by anyone
*  AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS REMAIN INTACT.
*  By using this code you agree to indemnify Klemen Stirn from any
*  liability that might arise from it's use.

*  Selling the code for this program, in part or full, without prior
*  written consent is expressly forbidden.

*  Using this code, in part or full, to create derivate work,
*  new scripts or products is expressly forbidden. Obtain permission
*  before redistributing this software over the Internet or in
*  any other medium. In all cases copyright and header must remain intact.
*  This Copyright is in full effect in any country that has International
*  Trade Agreements with the United States of America or
*  with the European Union.

*  Removing any of the copyright notices without purchasing a license
*  is expressly forbidden. To remove HESK copyright notice you must purchase
*  a license for this script. For more information on how to obtain
*  a license please visit the page below:
*  https://www.hesk.com/buy.php
*******************************************************************************/

define('IN_SCRIPT',1);
define('HESK_PATH','./');

/* Get all the required files and functions */
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');
require(HESK_PATH . 'inc/database.inc.php');

global $hesk_settings, $hesklang;

hesk_session_start();

/* Connect to database */
hesk_dbConnect();

$id_member = $_SESSION['id_member'];
$sqlMember = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."member` WHERE id_member='$id_member'");
$dataMember = hesk_dbFetchAssoc($sqlMember);

/* Print header */
$hesk_settings['tmp_title'] = $hesk_settings['hesk_title'] . ' - ' . $hesklang['register'];
require_once(HESK_PATH . 'inc/header.inc.php');
?>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td><span class="smaller"><a href="<?php echo $hesk_settings['site_url']; ?>" class="smaller"><?php echo $hesk_settings['site_title']; ?></a> &gt; <a href="<?php echo $hesk_settings['hesk_url']; ?>" class="smaller"><?php echo $hesk_settings['hesk_title']; ?></a> &gt; <?php echo $hesklang['update']; ?></span></td>
  </tr>
</table>
</td>
</tr>
<tr>
  <td><?php
/* This will handle error, success and notice messages */
hesk_handle_messages();
?>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="7" height="7"><img src="img/roundcornerslt.jpg" width="7" height="7" alt="" /></td>
        <td class="roundcornerstop"></td>
        <td><img src="img/roundcornersrt.jpg" width="7" height="7" alt="" /></td>
      </tr>
      <tr>
        <td class="roundcornersleft">&nbsp;</td>
        <td><!-- START FORM -->
          <form method="post" action="update_account.php" name="form1" enctype="multipart/form-data">
            <!-- Contact info -->
            <table border="0" width="100%">
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['email']; ?>:</td>
                <td width="80%"><input type="text" name="email" size="40" maxlength="50" value="<?php echo $dataMember['email']; ?>" /></td>
              </tr>
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['password']; ?>:</td>
                <td width="80%"><input type="password" name="password" size="40" maxlength="50" value="" /></td>
              </tr>
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['repass']; ?>:</td>
                <td width="80%"><input type="password" name="repass" size="40" maxlength="50" value="" /></td>
              </tr>
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['profile_pic']; ?>:</td>
                <td width="80%">
                    <?php if (file_exists('./img/uploads/'. $dataMember['id_member'] . '.jpg')):?>
                    <img class="profpic-img" src="./img/uploads/<?php echo $dataMember['id_member'];?>.jpg" />
                    <?php else: ?>
                    <img class="profpic-img" src="./img/uploads/nopic.jpg" />
                    <?php endif; ?>
                </td>
              </tr>
              <tr>
                <td style="text-align:right" width="150"></td>
                <td width="80%"><input type="file" name="profpic" size="40" /></td>
              </tr>
              <tr>
                <td style="text-align:right" width="150"></td>
                <td width="80%">Maximum size 50 Kb (jpg)</td>
              </tr>
            </table>
            <hr />
            <!-- Department and priority -->
            <table border="0" width="100%">
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['firstname']; ?>:</td>
                <td width="80%"><input type="text" name="firstname" size="40" maxlength="50" value="<?php echo $dataMember['nama_depan']; ?>" /></td>
              </tr>
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['lastname']; ?>:</td>
                <td width="80%"><input type="text" name="lastname" size="40" maxlength="50" value="<?php echo $dataMember['nama_belakang']; ?>" /></td>
               </tr>
               <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['gender']; ?>:</td>
                <td width="80%">
                    <select name="gender">
                        <option value="1" <?php echo ($dataMember['jenis_kelamin'] == 1) ? 'selected="selected"' : ''; ?> ><?php echo $hesklang['male'];?></option>
                        <option value="2" <?php echo ($dataMember['jenis_kelamin'] == 2) ? 'selected="selected"' : ''; ?> ><?php echo $hesklang['female'];?></option>
                    </select>
               </tr>
               <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['handphone']; ?>:</td>
                <td width="80%"><input type="text" name="handphone" size="40" maxlength="50" value="<?php echo $dataMember['hp']; ?>" /></td>
               </tr> 
            </table>
            <hr />
            <table border="0" width="100%">
                <tr>
                    <td style="text-align:right" width="150"><?php echo $hesklang['province']; ?>:</td>
                    <td width="80%">
                        <select name="province" onchange="update_city('<?php echo HESK_PATH; ?>',this.options[this.selectedIndex].value)">
                            <?php
                            $query = 'SELECT * FROM hesk_propinsi';
                            $result = hesk_dbQuery($query);
                            while ($prov = hesk_dbFetchAssoc($result)) {
                                ?>
                                <option value="<?php echo $prov['id_propinsi']; ?>" <?php echo ($dataMember['provinsi'] == $prov['id_propinsi']) ? 'selected="selected"' : ''; ?> >
                                    <?php echo $prov['propinsi']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </td>
                </tr>  
                <tr>
                    <td style="text-align:right" width="150"><?php echo $hesklang['city']; ?>:</td>
                    <td width="80%">
                        <select id="city-selection" name="city">
                            <?php
                            $id_province = $dataMember['provinsi'];
                            $query = 'SELECT * FROM hesk_kota WHERE id_propinsi=' . $id_province;
                            $result = hesk_dbQuery($query);
                            while ($city = hesk_dbFetchAssoc($result)) {
                                ?>
                                <option value="<?php echo $city['id_kota']; ?>" <?php echo ($dataMember['kota'] == $city['id_kota']) ? 'selected="selected"' : ''; ?> >
                                    <?php echo $city['kota']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </td>
                </tr>
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['address']; ?>: </td>
                <td width="80%"><input type="text" name="address" size="40" maxlength="50" value="<?php echo $dataMember['alamat']; ?>" /></td>
               </tr>
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['company']; ?>:</td>
                <td width="80%"><input type="text" name="company" size="40" maxlength="50" value="<?php echo $dataMember['perusahaan']; ?>" /></td>
              </tr>
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['phone']; ?>:</td>
                <td width="80%"><input type="text" name="phone" size="40" maxlength="50" value="<?php echo $dataMember['telp']; ?>" /></td>
               </tr>  
               <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['fax']; ?>:</td>
                <td width="80%"><input type="text" name="fax" size="40" maxlength="50" value="<?php echo $dataMember['fax']; ?>" /></td>
               </tr> 
               <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['website']; ?>:</td>
                <td width="80%"><input type="text" name="website" size="40" maxlength="50" value="<?php echo $dataMember['web']; ?>" /></td>
               </tr> 
            </table>
            <hr />
            
            <!-- Submit -->
            <div align="center">
              <table border="0">
                <tr>
                  <td>
                    <p align="center">
                      <input type="hidden" name="token" value="<?php hesk_token_echo(); ?>" />
                      <input type="submit" value="<?php echo $hesklang['update']; ?>" class="orangebutton"  onmouseover="hesk_btn(this,'orangebuttonover');" onmouseout="hesk_btn(this,'orangebutton');" />
                    </p>
                  </td>
                </tr>
              </table>
            </div>
          </form>
          <!-- END FORM --></td>
        <td class="roundcornersright">&nbsp;</td>
      </tr>
      <tr>
        <td><img src="img/roundcornerslb.jpg" width="7" height="7" alt="" /></td>
        <td class="roundcornersbottom"></td>
        <td width="7" height="7"><img src="img/roundcornersrb.jpg" width="7" height="7" alt="" /></td>
      </tr>
    </table>
<?php
      require_once(HESK_PATH . 'inc/footer.inc.php');
      ?>